#include	<stdio.h>
#include	"server.h"

void		server_read(t_fdc *fdc, int fd)
{
  printf("Un nouveau client s'est connecte\n");
  init_client(fdc, fd);
}

void		client_read(t_fdc *fdc, int fd)
{
  int   r;
  char buf[4096];

  r = xread(fd, buf, 4096);
  if (r > 0)
    {
      buf[r] = '\0';
      printf("%d\n",fd);
      printf(": ");
      printf("%s\n", buf);
    }
  else
    {
      printf("%d\n",fd);
      printf(": ");
      printf("Connexion closed\n");
      xclose(fd);
      fdc->fd_type[fd] = FD_FREE;
    }
}
